import time

from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

from base.page_base import BasePage


class BorrowingPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.a = By.XPATH, '//*[@id="mlayout"]/div[1]/div[2]/div/ul/li[3]/a'
        self.b = By.XPATH, '//*[@id="ng-app"]/body/div[2]/div/ul/li[1]/dl/dd[5]/a'
        self.c = By.XPATH, '//*[@id="borrowPublish"]/div[3]/input'
        self.d = By.XPATH, '//*[@id="borrowPublish"]/div[4]/select'
        self.e = By.XPATH, '//*[@id="borrowPublish"]/div[5]/input'
        self.f = By.XPATH, '//*[@id="borrowPublish"]/div[6]/input'
        #筹标期限
        self.g= By.XPATH, '//*[@id="borrowPublish"]/div[10]/select'
        #最低投资金额
        self.h= By.XPATH, '//*[@id="tender_amount_min"]'
        #最高
        self.i= By.XPATH, '//*[@id="tender_amount_max"]'
        self.j= By.XPATH, '//*[@id="borrow_contents"]'
        self.k = By.XPATH,'//*[@id="borrowPublish"]/div[16]/input'
        self.l= By.XPATH, '//*[@id="borrowForm"]'

    def get_borrowing(self, c, e, f, j, k='8888'):
        time.sleep(2)
        self.base_click(self.a)
        self.base_click(self.b)
        self.base_input(self.c, c)
        self.get_select_lndex(self.d,'4')
        self.base_input(self.e, e)
        self.base_input(self.f, f)
        self.get_select_lndex(self.g,'1')
        self.get_select_lndex(self.h,'1')
        self.get_select_lndex(self.i,'1')
        self.base_input(self.j, j)
        self.base_input(self.k, k)
        self.base_click(self.l)
